#include "stdafx.h"

#include "AudioManager.h"


template<> AudioManager*  Ogitors::Singleton<AudioManager>::ms_Singleton = 0;

 
AudioManager::AudioManager() 
{

}

AudioManager::~AudioManager()
{
}
bool binit = false;
void AudioManager::init()
{
  if (binit)
  {
	  OgreOggSound::OgreOggSoundManager::getSingletonPtr()->setSceneManager(OgitorsRoot::getSingleton().GetSceneManager());
	  //OgreOggSound::OgreOggSoundManager::getSingletonPtr()->createOggListener();

	  return;
  }
  binit = true;
	OgreOggSound::OgreOggSoundManager::getSingletonPtr()->init("Generic Hardware");
	OgreOggSound::OgreOggSoundManager::getSingletonPtr()->setMasterVolume(0.5);
#ifdef MUTE
	OgreOggSound::OgreOggSoundManager::getSingletonPtr()->setMasterVolume(0.0);
#endif
}

void AudioManager::update()
{
	OgreOggSound::OgreOggSoundManager::getSingletonPtr()->update();
}

 
 
 
 

	OgreOggSound::OgreOggISound * AudioManager::createSound(const Ogre::String & name , const std::string& file)
	{
		OgreOggSound::OgreOggISound *sound = NULL;
		if (!OgreOggSound::OgreOggSoundManager::getSingletonPtr()->hasSound(name))
			sound = OgreOggSound::OgreOggSoundManager::getSingletonPtr()->createSound(name, file,true);
		else
			sound = OgreOggSound::OgreOggSoundManager::getSingletonPtr()->getSound(name);

// 		if (sound)
// 			sound->play();
		return sound;
	}

 


  